package com.ruoyi.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Collections;
import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.pojo.VehicleModel;
import com.ruoyi.mapper.VehicleModelMapper;
import com.ruoyi.service.VehicleModelService;

@Service
public class VehicleModelServiceImpl extends ServiceImpl<VehicleModelMapper, VehicleModel> implements VehicleModelService {
    @Autowired
    private VehicleModelMapper vehicleModelMapper;

    @Override
    public List<VehicleModel> selectAllVehicleModel() {
        return vehicleModelMapper.getVehicleModelList();
    }

    @Override
    public boolean insertVehicleModel(VehicleModel vehicleModel) {
        return vehicleModelMapper.insertVehicleModel(vehicleModel);
    }

    @Override
    public boolean deleteVehicleModel(Long id) {
        return vehicleModelMapper.deleteVehicleModel(id);
    }

    @Override
    public boolean updateVehicleModel(VehicleModel vehicleModel) {
        boolean code = vehicleModelMapper.deleteVehicleModel(Long.valueOf(vehicleModel.getId()));
        if (code){
            vehicleModelMapper.insertVehicleModel(vehicleModel);
            return true;
        }else {
            return false;
        }
    }
}
